<script type="text/javascript">
    $(function() {
        $.fn.dataGridOptions.formSubFun("#form",'/modules/user/score/goods/doModify.html');
    });
</script>
<form id="form"  method="post" enctype="multipart/form-data">
<div class="popShow" style="padding-bottom:0;">
	<input name="id" value="${goods.id}" type="hidden">
	
    <div class="showItem">
    	<span>商品类别：</span>
    	<select name="categoryId" style="width:163px">
			<#list goodsCategoryList as item>
				<option value="${item.id}" <#if item.id == category.id>selected="selected"</#if>>${item.name}</option>
			</#list>
		</select>
    </div>
    <div class="showItem">
    	<span>商品名称：</span>
    	<input type="hidden" id="goodsHideName" name="goodsHideName" value="${goods.name}">
    	<input type="text" id="goodsName" name="name" maxlength="120" value="${goods.name}" class="easyui-validatebox" data-options="required: true" />
    </div>
    <div class="showItem">
    	<span>所需积分：</span>
    	<input type="text" name="score" maxlength="10" onKeyUp="value=value.replace(/[^0-9]/g,'')" value="${goods.score}" class="easyui-validatebox itemTxt" data-options="required: true,validType:'numOnly'"/><em>分</em>
    </div>
    <div class="showItem">
    	<span>市场价：</span>
    	<input type="text" name="marketPrice" maxlength="10" onKeyUp="value=value.replace(/[^0-9]/g,'')" value="${goods.marketPrice}" class="easyui-validatebox itemTxt" data-options="required: true,validType:'price'" /><em>元</em>
    </div>
    <div class="showItem">
    	<span>商品库存：</span>
    	<input type="text" name="store" maxlength="8" onKeyUp="value=value.replace(/[^0-9]/g,'')" value="${goods.store}" class="easyui-numberbox itemTxt" data-options="required: true,validType:'numOnly'" min="${goods.freezeStore+goods.sellAcount}"/><em>件</em>
    </div>
	<div class="showItem">
   		<span>虚拟商品：</span>
		<label><input type="radio" name="isVirtual" value="1" <#if goods.isVirtual == 1>checked="checked"</#if> />&nbsp;是</label>&nbsp;&nbsp;
	    <label><input type="radio" name="isVirtual" value="0" <#if goods.isVirtual == 0>checked="checked"</#if> />&nbsp;&nbsp;否</label>
    </div>
</div>
<div class="popForm" style="padding-top:0;">
	<div class="formitm">
		<label class="lab">封面图片：</label>
		<div class="ipt">
			<input type="file" name="file">	
		</div>
	</div>
	<div class="formitm">
		<label style="width:130px;" class="lab">&nbsp;</label>
		<div class="ipt" style="height:100px;">
			<img src="${image_server_url}${goods.picPath!}" height="100" width="100">	
		</div>
	</div>
    <div class="formitm">
		<label style="width:130px;" class="lab">商品详情：</label>
		<div style="margin-left:140px;color:#000;border:1px solid #dedede;" class="ipt">
			<textarea id="description" name="description" style="height:50px;">${goods.description!}</textarea>
		</div>
	</div>
	<div class="formitm">
		<label style="width:130px;" class="lab">商品属性信息：</label>
		<div style="margin-left:140px;color:#000;border:1px solid #dedede;" class="ipt">
			<textarea id="attribute" name="attribute" style="height:50px;">${goods.attribute!}</textarea>
		</div>
	</div>
	<div class="formitm">
		<label style="width:130px;" class="lab">备注：</label>
		<div style="margin-left:140px;color:#000;" class="ipt">
			<textarea name="remark" style="width:500px;" class="easyui-validatebox" maxlength="256">${goods.remark!}</textarea>
		</div>
	</div>
    
</div>
</form>
<!-- 编辑器 -->
<script type="text/javascript" src="/plugins/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="/plugins/uploadify/jquery.uploadify.js"></script>
<link rel="stylesheet" href="/plugins/uploadify/uploadify.css" type="text/css">
<script type="text/javascript">
	var image_server_url = $("#image_server_url").val();
    // 编辑器调用
    var tinymceEditor;
    tinymce.init({
        mode : "textareas",
        theme : "modern",//定义显示类别
        language:'zh_CN',//设置语言
        plugins: "fullscreen code preview textcolor",
        theme_advanced_toolbar_location : "top",//定义工具栏的位置
        theme_advanced_toolbar_align : "left", //定义工具栏工具的对其方式
        selector: "#description",
        theme_advanced_statusbar_location : "bottom",//定义输入框下方是否显示状态栏，默认不显示
        theme_advanced_resizing : true,//定义是否可以改变输入窗口大小
        menubar: false,//菜单栏
        toolbar:"fullscreen code styleselect removeformat bold italic alignleft aligncenter alignright fontsizeselect forecolor backcolor imageButton",
        theme_advanced_toolbar_location : "top",//定义工具栏的位置
        theme_advanced_toolbar_align : "left",//定义工具栏工具的对其方式
        toolbar_items_size: 'small',//工具栏图标大小
        setup: function (editor) {
            tinymceEditor = editor;
            editor.addButton('imageButton', {
                icon: 'image',
                onclick: function () {
                	var imgUrl;
                	$.layer({
        			    type: 1,
        			    closeBtn: [0, true],
        			    title: '选择图片',
        			    area: ['550px', '450px'],
        			    border: [0],
        			    page : {
        			    	html:'<div class="uploaderBox"><div class="uploadList"><ul class="filelist"></ul></div><div class="statusBar"><span class="okBtn">确定</span><span><em id="files" name="file"></em></span></div></div>'
        			    }
        			});
                	//图片上传插件
               		$('#files').uploadify({
       	              fileObjName : 'upload',
       	              buttonClass:'uploadBtn',
       	              buttonText:'选择&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
       	              fileTypeDesc:'Image Files',
       	              fileTypeExts:'*.gif; *.jpg; *.png',
       	              fileSizeLimit:'500',
       	           	  width:80,
       	              height:32,
       	              // uploadLimit:1000,
       	              swf:'/plugins/uploadify/uploadify.swf',
       	              uploader:image_server_url+"/upload/uploadifySave.html?nid=goods",
       	              onSelectError: function(file,errorCode,errorMsg){
       	                    if(errorCode==-110){
       	                    	layer.msg('上传的单张图片不能超过500K，请重新上传', 1, -1);
       	                    	return false;
       	                    }
       	                    else if(errorCode==-130){
       	                    	layer.msg('选择的文件类型跟设置的不匹配', 2, -1);
       	                    	return false;
       	                    }
       	              },
       	              onUploadSuccess:function(file,data, response) {
       	            	if(data!=null){
       	                	imgUrl = image_server_url+data;
       	                    $('.filelist').append("<li><a href='"+imgUrl+"' class='fileshow'><img src='"+imgUrl+"' width='110px' height='110px' /></a><i class='iconfont delImgUrl' title='点击删除图片'>&#xe628;</i></li>");
       	                }
       	              }
       	        	});
               		//确定并添加到编辑器
               		$(".okBtn").click(function(){
               			var img = "";
               			$(".filelist li a").each(function(){
               				img += $(this).html();
               			});
               			if(img != "" ){
               				//var img = '<img src="'+imgUrl+'" alt="">';
                            tinymceEditor.insertContent(img);
               			}
               			layer.closeAll();
               		})   
               		//删除图片
					  $(".delImgUrl").live("click",function(){
					    var _that = $(this);
					     $.ajax({
					       url : "/modules/user/score/goods/delPic.html?randomTime=" + (new Date()).getTime(),
					       dataType:'json',
					       data : {pathPic : $(this).prev().attr("src")},
					       success:function(data){
					          if(data.result){
					            _that.parents("li").remove();
					          }
					       }
					     })
					  })
                }
            });
        }, 
        statusbar  : false //控制底部状态栏是否显示
    });
	
    var tinymceEditor1;
    tinymce.init({
        mode : "textareas",
        theme : "modern",//定义显示类别
        language:'zh_CN',//设置语言
        plugins: "fullscreen code textcolor image",
        theme_advanced_toolbar_location : "top",//定义工具栏的位置
        theme_advanced_toolbar_align : "left", //定义工具栏工具的对其方式
        selector: "#attribute",
        theme_advanced_statusbar_location : "bottom",//定义输入框下方是否显示状态栏，默认不显示
        theme_advanced_resizing : true,//定义是否可以改变输入窗口大小
        menubar: false,//菜单栏
        toolbar:"fullscreen code styleselect removeformat bold italic alignleft aligncenter alignright fontsizeselect forecolor backcolor imageButton",
        theme_advanced_toolbar_location : "top",//定义工具栏的位置
        theme_advanced_toolbar_align : "left",//定义工具栏工具的对其方式
        toolbar_items_size: 'small',//工具栏图标大小
        setup: function (editor) {
            tinymceEditor1 = editor;
            editor.addButton('imageButton', {
                icon: 'image',
                onclick: function () {
                	var imgUrl;
                	$.layer({
        			    type: 1,
        			    closeBtn: [0, true],
        			    title: '选择图片',
        			    area: ['550px', '450px'],
        			    border: [0],
        			    page : {
        			    	html:'<div class="uploaderBox"><div class="uploadList"><ul class="filelist"></ul></div><div class="statusBar"><span class="okBtn">确定</span><span><em id="files1" name="file1"></em></span></div></div>'
        			    }
        			});
                	//图片上传插件
               		$('#files1').uploadify({
       	              fileObjName : 'upload',
       	              buttonClass:'uploadBtn',
       	              buttonText:'选择&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
       	              fileTypeDesc:'Image Files',
       	              fileTypeExts:'*.gif; *.jpg; *.png',
       	              fileSizeLimit:'500',
       	           	  width:80,
       	              height:32,
       	              // uploadLimit:1000,
       	              swf:'/plugins/uploadify/uploadify.swf',
       	              uploader:image_server_url+"/upload/uploadifySave.html?nid=goods",
       	              onSelectError: function(file,errorCode,errorMsg){
       	                    if(errorCode==-110){
       	                    	layer.msg('上传的单张图片不能超过500K，请重新上传', 1, -1);
       	                    	return false;
       	                    }
       	                    else if(errorCode==-130){
       	                    	layer.msg('选择的文件类型跟设置的不匹配', 2, -1);
       	                    	return false;
       	                    }
       	              },
       	              onUploadSuccess:function(file,data, response) {
       	            	if(data!=null){
       	                	imgUrl = image_server_url+data;
       	                    $('.filelist').append("<li><a href='"+imgUrl+"' class='fileshow'><img src='"+imgUrl+"' width='110px' height='110px' /></a><i class='iconfont delImgUrl1' title='点击删除图片'>&#xe628;</i></li>");
       	                }
       	              }
       	        	});
               		//确定并添加到编辑器
               		$(".okBtn").click(function(){
               			var img = "";
               			$(".filelist li a").each(function(){
               				img += $(this).html();
               			});
               			if(img != "" ){
               				//var img = '<img src="'+imgUrl+'" alt="">';
                            tinymceEditor1.insertContent(img);
               			}
               			layer.closeAll();
               		}) 
               		
               		//删除图片
				  	$(".delImgUrl1").live("click",function(){
				    	var _that = $(this);
				     	$.ajax({
				       		url : "/modules/user/score/goods/delPic.html?randomTime=" + (new Date()).getTime(),
				       		data : {pathPic : $(this).prev().attr("src")},
				       		success:function(data){
				          		if(data.result){
				            		_that.parents("li").remove();
				          		}
				       		}
				     	})
				  	})
                }
            });
        },
        statusbar  : false //控制底部状态栏是否显示
    });
    
    $(".fileshow").fancybox();
</script>